<template>
  <div>
    <!-- 导航 -->
    <nav class="headNav">
      <div class="container">
        <div class="menuContent">
          <ul class="menu">
            <!-- 最多可展示9个菜单 -->
            <router-link tag="li" class="indexPath" to="/index">
              <img class="homeImg" src="@/assets/images/home.png" alt="" />
              <span>首页</span>
            </router-link>
            <!-- 第一级 -->
            <li v-for="item in menuList" :key="item.id">
              <a @click="
                handleLink(
                  item.path, item.title, item.id, item.openWays
                )
                " :target="item.openWays === '1' ? '_blank' : ''"
                :class="item.imRequest === null ? 'noneClick' : ''">{{
                  item.title
                }}</a>
              <ul class="submenu">
                <!-- 第二级 -->
                <li v-for="(item1, index1) in item.children" :key="item1.imId">
                  <a @click="
                    handleLink(
                      item1.path, item1.title, item1.id, item1.openWays, index1, item1.ntCtgId
                    )
                    " :target="item1.openWays === '1' ? '_blank' : ''"
                    :class="item1.imRequest === null ? 'noneClick' : ''">{{
                      item1.title
                    }}</a>
                  <!-- 判断下一级是否存在 -->
                  <ul class="thirdmenu" v-if="item1.children && item1.children.length">
                    <!-- 第三级 -->
                    <li v-for="item2 in item1.children" :key="item2.imId">
                      <!-- {{ item2.imName }} -->
                      <a @click="
                        handleLink(
                          item2.path, item2.title, item2.id, item2.openWays
                        )
                        " :target="item2.openWays === '1' ? '_blank' : ''"
                        :class="item2.imRequest === null ? 'noneClick' : ''">{{
                          item2.imName
                        }}</a>
                    </li>
                  </ul>
                </li>
              </ul>
            </li>

          </ul>
        </div>
      </div>

    </nav>
  </div>
</template>
<script>
import Online from "@/components/personalCenter/online/online";
import { newColumnList } from "@/request/api/new"
export default {
  components: {
    Online,
  },
  data() {
    return {
      dataList: [
        {
          title: "科创服务",
          id: "1",
          children: [
            {
              title: "科创贷服务",
              id: "11",
              path: "/loanService",
              openWays: "0",
            },

            {
              title: "股权融资服务",
              id: "13",
              path: "/equityService",
              openWays: "0",
            },
            {
              title: "科研成果转化",
              id: "12",
              path: "/scientificResearch",
              openWays: "0",
            },
          ],
        },
        {
          title: "园区服务",
          id: "2",
          children: [
            {
              title: "智慧能源平台",
              id: "21",
              openWays: "1",
              path:
                "http://119.163.199.221:8311/statistic/shengshihuatong/index.html",
            },
            {
              title: "走进园区",
              id: "21",
              path: "/enterPark",
              openWays: "0",
            },
            {
              title: "入驻服务",
              id: "22",
              path: "/settleService",
              openWays: "0",
            },
            {
              title: "合同服务",
              id: "23",
              path: "/contractService",
              openWays: "0",
            },
            {
              title: "预订预约",
              id: "24",
              path: "/bookService",
              openWays: "0",
            },
            // {
            //   name: "班车服务",
            //   id: '25',
            //   path: "/shuttleService"
            // },
            {
              title: "物业服务",
              id: "26",
              path: "/propertyService",
              openWays: "0",
            },
          ],
        },
        {
          title: "其他服务",
          id: "23",
          children: [
            {
              title: "活动报名",
              id: "31",
              path: "/activity",
              openWays: "0",
            },
            {
              title: "项目路演",
              id: "32",
              path: "/roadShow",
              openWays: "0",
            },
            {
              title: "企业查询",
              id: "33",
              path: "/enterpriseQuery",
              openWays: "0",
            },
            {
              title: "奖补申请",
              id: "34",
              path: "/subsidyService",
              openWays: "0",
            },
            {
              title: "园区圈子",
              id: "36",
              path: "/parkCircle",
              openWays: "0",
            },
            {
              title: "问卷调查",
              id: "35",
              path: "/question",
              openWays: "0",
            },
          ],
        },
        // {
        //   title: "风险预警",
        //   id: "29",
        //   path: "/riskWarningOne",
        //   openWays: "0",
        // },
      ],
      logindataList: [
        {
          title: "科创服务",
          id: "1",
          children: [
            {
              title: "科创贷服务",
              id: "11",
              path: "/loanService",
              openWays: "0",
            },

            {
              title: "股权融资服务",
              id: "13",
              path: "/equityService",
              openWays: "0",
            },
            {
              title: "科研成果转化",
              id: "12",
              path: "/scientificResearch",
              openWays: "0",
            },
          ],
        },
        {
          title: "园区服务",
          id: "2",
          children: [
            {
              title: "智慧能源平台",
              id: "21",
              openWays: "1",
              path:
                "http://119.163.199.221:8311/statistic/shengshihuatong/index.html",
            },
            {
              title: "走进园区",
              id: "21",
              path: "/enterPark",
              openWays: "0",
            },
            {
              title: "入驻服务",
              id: "22",
              path: "/settleService",
              openWays: "0",
            },
            {
              title: "合同服务",
              id: "23",
              path: "/contractService",
              openWays: "0",
            },
            {
              title: "预订预约",
              id: "24",
              path: "/bookService",
              openWays: "0",
            },
            // {
            //   name: "班车服务",
            //   id: '25',
            //   path: "/shuttleService"
            // },
            {
              title: "物业服务",
              id: "26",
              path: "/propertyService",
              openWays: "0",
            },
          ],
        },
        {
          title: "其他服务",
          id: "23",
          children: [
            {
              title: "活动报名",
              id: "31",
              path: "/activity",
              openWays: "0",
            },
            {
              title: "项目路演",
              id: "32",
              path: "/roadShow",
              openWays: "0",
            },
            {
              title: "企业查询",
              id: "33",
              path: "/enterpriseQuery",
              openWays: "0",
            },
            {
              title: "奖补申请",
              id: "34",
              path: "/subsidyService",
              openWays: "0",
            },
            {
              title: "园区圈子",
              id: "36",
              path: "/parkCircle",
              openWays: "0",
            },
            {
              title: "问卷调查",
              id: "35",
              path: "/question",
              openWays: "0",
            },
          ],
        },
        {
          title: "风险预警",
          id: "29",
          path: "/riskWarningOne",
          openWays: "0",
        },
      ],
      menuList: [],
      show: -1,
      dialogVisible: false,
      form: {
        name: "",
      },
      title: "",
      formLabelWidth: "120px",
      rules: {
        name: [{ required: true, message: "请输入", trigger: "blur" }],
      },
      searchUrl: "",
      placeText: "请输入搜索关键字",
    };
  },
  created() {
    this.getMenuList();
  },
  methods: {
    // 获取资讯菜单列表
    getMenuList() {
      newColumnList().then((res) => {
        if (res.data.code === 200) {
          // “风险预警”只有政府账号、平台运营方账号、银行账号、担保机构账号、保险机构账号、基金机构账号，登录后可见
          if (window.sessionStorage.getItem("userInfo") !== null) {
            var userInfo = JSON.parse(window.sessionStorage.getItem("userInfo"));
            if(userInfo.registrationType==='8'||userInfo.registrationType==='2'||userInfo.registrationType==='3'||userInfo.registrationType==='12'||userInfo.registrationType==='13'||userInfo.registrationType==='7'){
              this.logindataList.unshift(res.data.result[0]);
              this.menuList = this.logindataList
            }else{
              this.dataList.unshift(res.data.result[0]);
              this.menuList = this.dataList
            }
          }else{
            this.dataList.unshift(res.data.result[0]);
            this.menuList = this.dataList
          }
        }
      });
    },
    // 回车键搜索
    seachEnter(e) {
      var keyCode = window.event ? e.keyCode : e.which;
      if (keyCode == 13) {
        this.handleSubmit(); //搜索按钮的回调
      }
    },
    // 菜单跳转链接
    handleLink(url, name, id, type, index, ntCtgId) {
      if (type === '1') {
        window.open(url);
      } else {
        if (url === '/') {
          this.$router.push({
            name: "newList",
            query: {
              id: ntCtgId,
              index: index,
              name: name
            },
          });
        } else {
          this.$router.push(url);
        }
      }
    },
  },
};
</script>
<style lang="less" scoped>
@import "./nav.less";
</style>
